home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: September 12, 1997
- //
- // Description:
- // This script is use to display and update the grid spacing options.
- //
- // Input Arguments:
- // int showOptionBox true - show the option box dialog
- // false - just execute the command
- //
- // Return Value:
- // None.
- //
-
-
- //
- // Procedure Name:
- // textureWindowPanelName
- //
- // Description:
- // return the texture window panel name.
- //
- // Input Arguments:
- //
- //
- // Return Value:
- // texture window panel name
- //
- proc string textureWindowPanelName()
- {
- string $texWinName[] = `getPanel -sty polyTexturePlacementPanel`;
- return $texWinName[0];
- }
-
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- // There don't seem to be any options
-
- // If you wanted these values to be saved between sessions you should
- // put in your optionVars here
-
- // Grid spacing.
- //
- if ($forceFactorySettings || !`optionVar -exists textureWindowGridSpacing`) {
- optionVar -floatValue textureWindowGridSpacing 0.1;
- }
-
- // Grid subdivisions.
- //
- if ($forceFactorySettings || !`optionVar -exists textureWindowGridDivisions`) {
- optionVar -floatValue textureWindowGridDivisions 2.0;
- }
-
- // Grid size.
- //
- if ($forceFactorySettings || !`optionVar -exists textureWindowGridSize`) {
- optionVar -floatValue textureWindowGridSize 1.0;
- }
-
- // Display grid axes.
- //
- if ($forceFactorySettings || !`optionVar -exists textureWindowDisplayGridAxes`) {
- optionVar -intValue textureWindowDisplayGridAxes true;
- }
-
- // Display grid lines.
- //
- if ($forceFactorySettings || !`optionVar -exists textureWindowDisplayGridLines`) {
- optionVar -intValue textureWindowDisplayGridLines true;
- }
-
- // Display division lines.
- //
- if ($forceFactorySettings || !`optionVar -exists textureWindowDisplayDivisionLines`) {
- optionVar -intValue textureWindowDisplayDivisionLines false;
- }
-
- // Display grid labels.
- //
- if ($forceFactorySettings || !`optionVar -exists textureWindowDisplayGridLabels`) {
- optionVar -intValue textureWindowDisplayGridLabels true;
- }
-
- // Display location of labels.
- //
- if ($forceFactorySettings || !`optionVar -exists textureWindowDisplayGridLabelPosition`) {
- optionVar -stringValue textureWindowDisplayGridLabelPosition "axis";
- }
- }
-
- //
- // Procedure Name:
- // tvGridSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc tvGridSetup(string $parent, int $forceFactorySettings)
- {
- setParent $parent;
-
- setOptionVars($forceFactorySettings);
-
- // Get the grid dimension values.
- //
- float $spacing = `optionVar -query textureWindowGridSpacing`;
- float $size = `optionVar -query textureWindowGridSize`;
- int $divisions = `optionVar -query textureWindowGridDivisions`;
-
- // Get the grid display values.
- //
- int $displayAxes = `optionVar -query textureWindowDisplayGridAxes`;
- int $displayGridLines = `optionVar -query textureWindowDisplayGridLines`;
- int $displayDivisionLines = `optionVar -query textureWindowDisplayDivisionLines`;
- int $displayGridLabels = `optionVar -query textureWindowDisplayGridLabels`;
- string $labelPosition = `optionVar -query textureWindowDisplayGridLabelPosition`;
- int $location;
-
- // Update the grid controls.
- //
- floatFieldGrp -edit -value1 $size TextureWindowGridOptionsSize;
- floatFieldGrp -edit -value1 $spacing TextureWindowGridOptionsDistance;
- intSliderGrp -edit -value $divisions TextureWindowGridOptionsDivisions;
-
- // Update the state of the display controls.
- //
- checkBoxGrp -edit -value1 $displayAxes TextureWindowGridOptionsDisplayAxes;
- checkBoxGrp -edit -value1 $displayGridLines TextureWindowGridOptionsDisplayGridLines;
- checkBoxGrp -edit -value1 $displayDivisionLines TextureWindowGridOptionsDisplayDivisionLines;
-
- if ($displayGridLabels) {
- if ("axis" == $labelPosition) {
- $location = 2;
- } else {
- $location = 3;
- }
- } else {
- $location = 1;
- }
- radioButtonGrp -edit -select $location TextureWindowGridOptionsLabelPosition;
- }
-
- //
- // Procedure Name:
- // tvGridCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc tvGridCallback(string $parent, int $doIt)
- {
- // Get the grid values from the UI.
- //
- float $size = `floatFieldGrp -query -value1 TextureWindowGridOptionsSize`;
- float $spacing = `floatFieldGrp -query -value1 TextureWindowGridOptionsDistance`;
- int $divisions = `intSliderGrp -query -value TextureWindowGridOptionsDivisions`;
-
- // Get the grid display values.
- //
- int $displayAxes = `checkBoxGrp -query -value1 TextureWindowGridOptionsDisplayAxes`;
- int $displayGridLines = `checkBoxGrp -query -value1 TextureWindowGridOptionsDisplayGridLines`;
- int $displayDivisionLines = `checkBoxGrp -query -value1 TextureWindowGridOptionsDisplayDivisionLines`;
- int $labelPosition = `radioButtonGrp -query -select TextureWindowGridOptionsLabelPosition`;
-
- // Verify the values.
- //
- if (1.0 > $size) {
- error ("Length and Width value may not be less than 1.0");
- return;
- }
- if (0.0 >= $spacing) {
- error ("Grid Line spacing must be greater than 0.0");
- return;
- }
-
- // Update the grid values.
- //
- optionVar -floatValue textureWindowGridSpacing $spacing;
- optionVar -floatValue textureWindowGridSize $size;
- optionVar -floatValue textureWindowGridDivisions $divisions;
-
- // Update the grid display values.
- //
- optionVar -intValue textureWindowDisplayGridAxes $displayAxes;
- optionVar -intValue textureWindowDisplayGridLines $displayGridLines;
- optionVar -intValue textureWindowDisplayDivisionLines $displayDivisionLines;
-
- if (1 == $labelPosition) {
- optionVar -intValue textureWindowDisplayGridLabels false;
- } else if (2 == $labelPosition) {
- optionVar -stringValue textureWindowDisplayGridLabelPosition "axis";
- optionVar -intValue textureWindowDisplayGridLabels true;
- } else {
- optionVar -stringValue textureWindowDisplayGridLabelPosition "edge";
- optionVar -intValue textureWindowDisplayGridLabels true;
- }
-
- if ($doIt) {
- performTextureViewGridOptions 0;
- addToRecentCommandQueue "performTextureViewGridOptions 0" "TextureViewGrid";
- }
- }
-
- //
- // Procedure Name:
- // tvGridOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc tvGridOptions()
- {
- // Name of the command for this option box.
- //
- string $commandName = "tvGrid";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // STEP 1: Get the option box.
- // ============================
- //
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // STEP 2: Pass the command name to the option box.
- // =================================================
- //
- // Any default option box behaviour based on the command name is set
- // up with this call. For example, updating the 'Help' menu item with
- // the name of the command.
- //
- setOptionBoxCommandName($commandName);
-
- // STEP 3: Activate the default UI template.
- // ==========================================
- //
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // STEP 4: Create option box contents.
- // ===================================
- //
- // This, of course, will vary from option box to option box.
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -tabsVisible 0 -scrollable 1;
-
- string $parent = `columnLayout -adjustableColumn 1 -rowSpacing 4`;
-
- // Grid size.
- //
- frameLayout -label "Size" -labelAlign "center" -collapsable false -collapse false;
- columnLayout;
-
- $gridSize = `floatFieldGrp -label "Length and Width"
- -extraLabel "units"
- TextureWindowGridOptionsSize`;
-
- $gridDistance = `floatFieldGrp -label "Grid Lines Every"
- -extraLabel "units"
- TextureWindowGridOptionsDistance`;
-
- $divisions = `intSliderGrp -label "Subdivisions"
- -field true
- -min 2 -max 256 -fieldMinValue 2 -fieldMaxValue 4096 -step 1
- TextureWindowGridOptionsDivisions`;
-
- setParent ..;
- setParent ..;
-
- frameLayout -label "Display" -labelAlign "center" -collapsable false -collapse false;
- columnLayout;
-
- checkBoxGrp -numberOfCheckBoxes 1 -label "" -label1 "Axes"
- TextureWindowGridOptionsDisplayAxes;
-
- checkBoxGrp -numberOfCheckBoxes 1 -label "" -label1 "Grid Lines"
- TextureWindowGridOptionsDisplayGridLines;
-
- checkBoxGrp -numberOfCheckBoxes 1 -label "" -label1 "Subdivision Lines"
- TextureWindowGridOptionsDisplayDivisionLines;
-
- radioButtonGrp -numberOfRadioButtons 3 -label "Grid Numbers"
- -labelArray3 "Hide" "On Axes" "Along Edge"
- TextureWindowGridOptionsLabelPosition;
-
- setParent ..;
- setParent ..;
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
- //
- // Provide more descriptive labels for the buttons. This is not
- // necessary, but in some cases, for example, a button labelled
- // 'Create' may be more meaningful to the user than one labelled
- // 'Apply'.
- //
- // Disable those buttons that are not applicable to the option box.
- //
- // Attach actions to those buttons that are applicable to the option
- // box. Note that the 'Close' button has a default action attached
- // to it that will hide the window. If a a custom action is
- // attached to the 'Close' button then be sure to call the 'hide the
- // option box' procedure within the custom action so that the option
- // box is hidden properly.
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 1 + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- setOptionBoxTitle("UV Texture Editor Grid Options");
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "UVEditorGrid" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval (($setup + " " + $parent + " " + 0));
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- proc string assembleCmd()
- {
- string $cmd;
-
- setOptionVars(false);
-
- string $winName = textureWindowPanelName();
-
- float $spacing = `optionVar -query textureWindowGridSpacing`;
- int $divisions = `optionVar -query textureWindowGridDivisions`;
- float $size = `optionVar -query textureWindowGridSize`;
-
- int $displayAxes = `optionVar -query textureWindowDisplayGridAxes`;
- int $displayGridLines = `optionVar -query textureWindowDisplayGridLines`;
- int $displayDivisionLines = `optionVar -query textureWindowDisplayDivisionLines`;
- int $displayGridLabels = `optionVar -query textureWindowDisplayGridLabels`;
- string $labelPosition = `optionVar -query textureWindowDisplayGridLabelPosition`;
-
- $cmd = "textureWindow -edit -spacing " + $spacing
- + " -divisions " + $divisions
- + " -size " + $size
- + " -displayAxes " + $displayAxes
- + " -displayGridLines " + $displayGridLines
- + " -displayDivisionLines " + $displayDivisionLines
- + " -displayLabels " + $displayGridLabels
- + " -labelPosition " + $labelPosition
- + " " + $winName + ";"
- ;
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performTextureViewGridOptions
- //
- // Description:
- // Perform the grid command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the grid command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- global proc string performTextureViewGridOptions(int $action)
- {
- string $cmd = "";
-
- switch ($action) {
-
- // Execute the command.
- //
- case 0:
- // Get the command.
- //
- $cmd = `assembleCmd`;
-
- // Execute the command with the option settings.
- //
- eval($cmd);
- break;
-
- // Show the option box.
- //
- case 1:
- tvGridOptions;
- break;
-
- // Return the command string.
- //
- case 2:
- // Get the command.
- //
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-